Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for generic Hashers #19

Merged
merged 1 commit into from
Feb 4, 2024
Merged

Add support for generic Hashers #19

merged 1 commit into from
Feb 4, 2024

Conversation

Maneren
Copy link
Contributor

@Maneren Maneren commented Feb 3, 2024

Hello. Firstly, thank you, I am using this crate in my hobby project and it's been very handy so far.

However, I ran into a few minor issues, the most noticeable being missing support for other Hashers (FxHasher in my case). So if you don't mind, I made this PR (and possibly will make more for the rest).

I tried following the std's HashMap implementation as closely as possible and based on both the docstring test and my project, it seems to work great.

Copy link

codecov bot commented Feb 4, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (62f4da1) 100.00% compared to head (4b7209f) 97.83%.

Files Patch % Lines
src/default_hashmap.rs 41.66% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##            master      #19      +/-   ##
===========================================
- Coverage   100.00%   97.83%   -2.17%     
===========================================
  Files            3        2       -1     
  Lines          315      323       +8     
===========================================
+ Hits           315      316       +1     
- Misses           0        7       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MitchellBerend
Copy link
Owner

Hello, thanks for your contribution. I never implemented this functionality since I never needed it but if it helps you I would be glad to add it. When I read through the code I thought, why not also add it to the BTreeMap but that doesn't seem to have a with_hasher function for some reason.

@MitchellBerend MitchellBerend merged commit 0e72b41 into MitchellBerend:master Feb 4, 2024
5 of 7 checks passed
@Maneren
Copy link
Contributor Author

Maneren commented Feb 4, 2024

Thanks. And as far as I understand it, BTreeMap uses just Ord instead of Hash, so it doesn't need a Hasher at all. Also, I will send a related PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants